///////////////////////////////////////////////////////////////////////////////
// Name:        wxAutoTextCtrl.h
// Purpose:     wxAutoTextCtrl class declaration.
// Author:      Priyank Bolia <soft@priyank.in>
// Modified by: Ville Lindell <vdell@users.sf.net>
// Created:     25.01.06
// Copyright:   (c) Priyank Bolia
// Licence:     wxWindows licence <http://wxwidgets.org/licence3.txt>
///////////////////////////////////////////////////////////////////////////////

#pragma once

#include "../../ColligereAutoCompleteControlBase.hpp"

/**
 * @brief A text control which automatically predicts the list of possible values,
 * based on the user input, and completes the text.
 * @detail NB: Use up & down arrow keys to see the list of possible values as you
 * keep typing, the valid range of values.
 *
 *
 * @par requirements
 * wxWidgets 2.6.0 or later\n
 *
 * @version 1.0
 * first version
 *
 * @date 01-25-2006
 *
 * @author Priyank Bolia <soft@priyank.in>
 *
 * @par license wxWindows licence <http://wxwidgets.org/licence3.txt>
 * Copyright 2005 Priyank Bolia. All rights reserved.
 * 
 * @example
 * wxArrayString strArray;
 * strArray.Add("Priya");
 * strArray.Add("Priyank");
 * strArray.Add("Priyanka");
 * strArray.Add("Bolia");
 * wxAutoTextCtrl *pAutoTextCtrl = new wxAutoTextCtrl(this, wxID_ANY, wxEmptyString, strArray);
 *
 * @todo 
 *
 * @bug 
 *
 */
class wxAutoTextCtrl : public wxTextCtrl,
	public col::AutoCompleteControlBase
{
public:
	wxAutoTextCtrl();

	/**
	 * Constructor
	 * @param parent	Parent window pointer
	 * @param id		Control ID
	 * @param value		Text control value
	 * @param pos		Position of the control
	 * @param size		Size of the control
	 * @param style		Style values for the text control
	 * @param validator	Validator for validating the user input
	 * @param name		Name of the control.
	 */
	wxAutoTextCtrl ( wxWindow* parent, wxWindowID id = wxID_ANY, 
		const wxString& value = wxEmptyString, 
		const wxPoint& pos = wxDefaultPosition, 
		const wxSize& size = wxDefaultSize, long style = 0, 
		const wxValidator& validator = wxDefaultValidator, 
		const wxString& name = "Auto-Text Control" );
private:
	/**
	 * Event handler for text change event of the text control.
	 * @detail Used for updating/predicting the text control value, based on the user input.
	 * @param &event Text change event
	 */
	void OnTextChange ( wxCommandEvent &rEvent );

	/**
	 * Event handler for char input.
	 * @detail Used to handle the backspace and delete char press events.
	 * @param &event 
	 */
	void OnChar ( wxKeyEvent &rEvent );

	/**
	 * Event handler for key down.
	 * @detail Used to trap the up & down arrow keys and change the text control values accordingly.
	 * @param &event 
	 */
	void OnKeyDown ( wxKeyEvent &rEvent );

	//! Array of valid user inputs.
	wxArrayString mStrValues;
	//! Key code of the last key pressed.
	wxInt32 mKeyCode;	
	//! Index of the text control value in the list of valid values.
	wxInt32 mArrayIndex;

	DECLARE_DYNAMIC_CLASS ( wxAutoTextCtrl )
};